/**
 *
 */
import Util;
import OSS;
import OpenPlatform;
import OSSUtil;
import FileForm;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    cn-beijing = 'multisearch.cn-beijing.aliyuncs.com',
    cn-hangzhou = 'multisearch.cn-hangzhou.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('videosearch', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AddDeletionAudioTaskRequest {
  audioId?: string(name='AudioId'),
  clientToken?: string(name='ClientToken'),
  instanceId?: string(name='InstanceId'),
}

model AddDeletionAudioTaskResponseBody = {
  data?: boolean(name='Data'),
  requestId?: string(name='RequestId'),
}

model AddDeletionAudioTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AddDeletionAudioTaskResponseBody(name='body'),
}

async function addDeletionAudioTaskWithOptions(request: AddDeletionAudioTaskRequest, runtime: Util.RuntimeOptions): AddDeletionAudioTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.audioId)) {
    body['AudioId'] = request.audioId;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddDeletionAudioTask',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addDeletionAudioTask(request: AddDeletionAudioTaskRequest): AddDeletionAudioTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return addDeletionAudioTaskWithOptions(request, runtime);
}

model AddDeletionVideoTaskRequest {
  clientToken?: string(name='ClientToken', example='clientToken'),
  instanceId?: string(name='InstanceId'),
  videoId?: string(name='VideoId', example='testVideoId'),
}

model AddDeletionVideoTaskResponseBody = {
  data?: boolean(name='Data', example='true'),
  requestId?: string(name='RequestId', example='1ABBE852-6313-49F9-BF8A-6FDF9A4C0617'),
}

model AddDeletionVideoTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AddDeletionVideoTaskResponseBody(name='body'),
}

async function addDeletionVideoTaskWithOptions(request: AddDeletionVideoTaskRequest, runtime: Util.RuntimeOptions): AddDeletionVideoTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.videoId)) {
    body['VideoId'] = request.videoId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddDeletionVideoTask',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addDeletionVideoTask(request: AddDeletionVideoTaskRequest): AddDeletionVideoTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return addDeletionVideoTaskWithOptions(request, runtime);
}

model AddSearchAudioTaskRequest {
  audioFile?: string(name='AudioFile', example='http://xxx'),
  audioUrl?: string(name='AudioUrl', example='Http://xxx'),
  callbackUrl?: string(name='CallbackUrl', example='http://xxx'),
  clientToken?: string(name='ClientToken', example='1'),
  contentSource?: int32(name='ContentSource', example='1'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='1'),
  needFeatureFile?: int32(name='NeedFeatureFile', example='0'),
  queryTags?: string(name='QueryTags', example='test'),
  resourceType?: int32(name='ResourceType', example='1'),
  returnAudioNumber?: int32(name='ReturnAudioNumber', example='1'),
  sort?: int32(name='Sort', example='1'),
}

model AddSearchAudioTaskAdvanceRequest {
  audioFileObject?: readable(name='AudioFile', example='http://xxx'),
  audioUrl?: string(name='AudioUrl', example='Http://xxx'),
  callbackUrl?: string(name='CallbackUrl', example='http://xxx'),
  clientToken?: string(name='ClientToken', example='1'),
  contentSource?: int32(name='ContentSource', example='1'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='1'),
  needFeatureFile?: int32(name='NeedFeatureFile', example='0'),
  queryTags?: string(name='QueryTags', example='test'),
  resourceType?: int32(name='ResourceType', example='1'),
  returnAudioNumber?: int32(name='ReturnAudioNumber', example='1'),
  sort?: int32(name='Sort', example='1'),
}

model AddSearchAudioTaskResponseBody = {
  data?: {
    taskId?: string(name='TaskId', example='1'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='123'),
}

model AddSearchAudioTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AddSearchAudioTaskResponseBody(name='body'),
}

async function addSearchAudioTaskWithOptions(request: AddSearchAudioTaskRequest, runtime: Util.RuntimeOptions): AddSearchAudioTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.audioFile)) {
    body['AudioFile'] = request.audioFile;
  }
  if (!Util.isUnset(request.audioUrl)) {
    body['AudioUrl'] = request.audioUrl;
  }
  if (!Util.isUnset(request.callbackUrl)) {
    body['CallbackUrl'] = request.callbackUrl;
  }
  if (!Util.isUnset(request.contentSource)) {
    body['ContentSource'] = request.contentSource;
  }
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.needFeatureFile)) {
    body['NeedFeatureFile'] = request.needFeatureFile;
  }
  if (!Util.isUnset(request.queryTags)) {
    body['QueryTags'] = request.queryTags;
  }
  if (!Util.isUnset(request.resourceType)) {
    body['ResourceType'] = request.resourceType;
  }
  if (!Util.isUnset(request.returnAudioNumber)) {
    body['ReturnAudioNumber'] = request.returnAudioNumber;
  }
  if (!Util.isUnset(request.sort)) {
    body['Sort'] = request.sort;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddSearchAudioTask',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addSearchAudioTask(request: AddSearchAudioTaskRequest): AddSearchAudioTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return addSearchAudioTaskWithOptions(request, runtime);
}

async function addSearchAudioTaskAdvance(request: AddSearchAudioTaskAdvanceRequest, runtime: Util.RuntimeOptions): AddSearchAudioTaskResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.isUnset(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videosearch',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = null;

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var addSearchAudioTaskReq = new AddSearchAudioTaskRequest{};
  OpenApiUtil.convert(request, addSearchAudioTaskReq);

  if(!Util.isUnset(request.audioFileObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.audioFileObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    addSearchAudioTaskReq.audioFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var addSearchAudioTaskResp = addSearchAudioTaskWithOptions(addSearchAudioTaskReq, runtime);
  return addSearchAudioTaskResp;
}

model AddSearchVideoTaskRequest {
  callbackUrl?: string(name='CallbackUrl', example='http://testcallback.aliyun.com'),
  clientToken?: string(name='ClientToken', example='clientToken'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='vs-ix****t8'),
  needFeatureFile?: int32(name='NeedFeatureFile', example='0'),
  queryTags?: string(name='QueryTags', example='testVideoTag|testVideoTag1'),
  replaceStorageThreshold?: float(name='ReplaceStorageThreshold', example='0.75'),
  returnVideoNumber?: int32(name='ReturnVideoNumber', example='10'),
  searchType?: int32(name='SearchType', example='1'),
  sort?: int32(name='Sort', example='1'),
  storageType?: int32(name='StorageType', example='2'),
  videoFile?: string(name='VideoFile', example='file'),
  videoId?: string(name='VideoId', example='testVideoId'),
  videoTags?: string(name='VideoTags', example='testVideoTag'),
  videoUrl?: string(name='VideoUrl', example='https://mediaai-test-huadong2.oss-cn-shanghai.aliyuncs.com/perf/1_480p_25M.mp4'),
}

model AddSearchVideoTaskAdvanceRequest {
  callbackUrl?: string(name='CallbackUrl', example='http://testcallback.aliyun.com'),
  clientToken?: string(name='ClientToken', example='clientToken'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='vs-ix****t8'),
  needFeatureFile?: int32(name='NeedFeatureFile', example='0'),
  queryTags?: string(name='QueryTags', example='testVideoTag|testVideoTag1'),
  replaceStorageThreshold?: float(name='ReplaceStorageThreshold', example='0.75'),
  returnVideoNumber?: int32(name='ReturnVideoNumber', example='10'),
  searchType?: int32(name='SearchType', example='1'),
  sort?: int32(name='Sort', example='1'),
  storageType?: int32(name='StorageType', example='2'),
  videoFileObject?: readable(name='VideoFile', example='file'),
  videoId?: string(name='VideoId', example='testVideoId'),
  videoTags?: string(name='VideoTags', example='testVideoTag'),
  videoUrl?: string(name='VideoUrl', example='https://mediaai-test-huadong2.oss-cn-shanghai.aliyuncs.com/perf/1_480p_25M.mp4'),
}

model AddSearchVideoTaskResponseBody = {
  data?: {
    taskId?: string(name='TaskId', example='200001'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='1ABBE852-6313-49F9-BF8A-6FDF9A4C0617'),
}

model AddSearchVideoTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AddSearchVideoTaskResponseBody(name='body'),
}

async function addSearchVideoTaskWithOptions(request: AddSearchVideoTaskRequest, runtime: Util.RuntimeOptions): AddSearchVideoTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.callbackUrl)) {
    body['CallbackUrl'] = request.callbackUrl;
  }
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.needFeatureFile)) {
    body['NeedFeatureFile'] = request.needFeatureFile;
  }
  if (!Util.isUnset(request.queryTags)) {
    body['QueryTags'] = request.queryTags;
  }
  if (!Util.isUnset(request.replaceStorageThreshold)) {
    body['ReplaceStorageThreshold'] = request.replaceStorageThreshold;
  }
  if (!Util.isUnset(request.returnVideoNumber)) {
    body['ReturnVideoNumber'] = request.returnVideoNumber;
  }
  if (!Util.isUnset(request.searchType)) {
    body['SearchType'] = request.searchType;
  }
  if (!Util.isUnset(request.sort)) {
    body['Sort'] = request.sort;
  }
  if (!Util.isUnset(request.storageType)) {
    body['StorageType'] = request.storageType;
  }
  if (!Util.isUnset(request.videoFile)) {
    body['VideoFile'] = request.videoFile;
  }
  if (!Util.isUnset(request.videoId)) {
    body['VideoId'] = request.videoId;
  }
  if (!Util.isUnset(request.videoTags)) {
    body['VideoTags'] = request.videoTags;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddSearchVideoTask',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addSearchVideoTask(request: AddSearchVideoTaskRequest): AddSearchVideoTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return addSearchVideoTaskWithOptions(request, runtime);
}

async function addSearchVideoTaskAdvance(request: AddSearchVideoTaskAdvanceRequest, runtime: Util.RuntimeOptions): AddSearchVideoTaskResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.isUnset(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videosearch',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = null;

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var addSearchVideoTaskReq = new AddSearchVideoTaskRequest{};
  OpenApiUtil.convert(request, addSearchVideoTaskReq);

  if(!Util.isUnset(request.videoFileObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoFileObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    addSearchVideoTaskReq.videoFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var addSearchVideoTaskResp = addSearchVideoTaskWithOptions(addSearchVideoTaskReq, runtime);
  return addSearchVideoTaskResp;
}

model AddStorageAudioTaskRequest {
  audioFile?: string(name='AudioFile', example='http://xxx'),
  audioId?: string(name='AudioId', example='1'),
  audioTags?: string(name='AudioTags', example='test'),
  audioUrl?: string(name='AudioUrl', example='http://xxx'),
  callbackUrl?: string(name='CallbackUrl', example='http://xxx'),
  clientToken?: string(name='ClientToken', example='1'),
  contentSource?: int32(name='ContentSource', example='1'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='1'),
  sort?: int32(name='Sort', example='1'),
}

model AddStorageAudioTaskAdvanceRequest {
  audioFileObject?: readable(name='AudioFile', example='http://xxx'),
  audioId?: string(name='AudioId', example='1'),
  audioTags?: string(name='AudioTags', example='test'),
  audioUrl?: string(name='AudioUrl', example='http://xxx'),
  callbackUrl?: string(name='CallbackUrl', example='http://xxx'),
  clientToken?: string(name='ClientToken', example='1'),
  contentSource?: int32(name='ContentSource', example='1'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='1'),
  sort?: int32(name='Sort', example='1'),
}

model AddStorageAudioTaskResponseBody = {
  data?: {
    taskId?: string(name='TaskId', example='1'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='123'),
}

model AddStorageAudioTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AddStorageAudioTaskResponseBody(name='body'),
}

async function addStorageAudioTaskWithOptions(request: AddStorageAudioTaskRequest, runtime: Util.RuntimeOptions): AddStorageAudioTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.contentSource)) {
    query['ContentSource'] = request.contentSource;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.audioFile)) {
    body['AudioFile'] = request.audioFile;
  }
  if (!Util.isUnset(request.audioId)) {
    body['AudioId'] = request.audioId;
  }
  if (!Util.isUnset(request.audioTags)) {
    body['AudioTags'] = request.audioTags;
  }
  if (!Util.isUnset(request.audioUrl)) {
    body['AudioUrl'] = request.audioUrl;
  }
  if (!Util.isUnset(request.callbackUrl)) {
    body['CallbackUrl'] = request.callbackUrl;
  }
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.sort)) {
    body['Sort'] = request.sort;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddStorageAudioTask',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addStorageAudioTask(request: AddStorageAudioTaskRequest): AddStorageAudioTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return addStorageAudioTaskWithOptions(request, runtime);
}

async function addStorageAudioTaskAdvance(request: AddStorageAudioTaskAdvanceRequest, runtime: Util.RuntimeOptions): AddStorageAudioTaskResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.isUnset(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videosearch',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = null;

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var addStorageAudioTaskReq = new AddStorageAudioTaskRequest{};
  OpenApiUtil.convert(request, addStorageAudioTaskReq);

  if(!Util.isUnset(request.audioFileObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.audioFileObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    addStorageAudioTaskReq.audioFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var addStorageAudioTaskResp = addStorageAudioTaskWithOptions(addStorageAudioTaskReq, runtime);
  return addStorageAudioTaskResp;
}

model AddStorageVideoTaskRequest {
  callbackUrl?: string(name='CallbackUrl', example='http://callbacktest.aliyun.com'),
  clientToken?: string(name='ClientToken', example='c86d03d1-253e-4622-a4b1-195f945bceeb'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='vs-ix****t8'),
  sort?: int32(name='Sort', example='1'),
  storageInfo?: int32(name='StorageInfo', example='1'),
  videoFile?: string(name='VideoFile', example='file'),
  videoId?: string(name='VideoId', example='testVideoId'),
  videoTags?: string(name='VideoTags', example='testVideoTag'),
  videoUrl?: string(name='VideoUrl', example='https://mediaai-test-huadong2.oss-cn-shanghai.aliyuncs.com/perf/1****5M.mp4'),
}

model AddStorageVideoTaskAdvanceRequest {
  callbackUrl?: string(name='CallbackUrl', example='http://callbacktest.aliyun.com'),
  clientToken?: string(name='ClientToken', example='c86d03d1-253e-4622-a4b1-195f945bceeb'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='vs-ix****t8'),
  sort?: int32(name='Sort', example='1'),
  storageInfo?: int32(name='StorageInfo', example='1'),
  videoFileObject?: readable(name='VideoFile', example='file'),
  videoId?: string(name='VideoId', example='testVideoId'),
  videoTags?: string(name='VideoTags', example='testVideoTag'),
  videoUrl?: string(name='VideoUrl', example='https://mediaai-test-huadong2.oss-cn-shanghai.aliyuncs.com/perf/1****5M.mp4'),
}

model AddStorageVideoTaskResponseBody = {
  data?: {
    taskId?: string(name='TaskId', example='100000'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='C86D03D1-253E-4622-A4B1-195F945BCEEB'),
}

model AddStorageVideoTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: AddStorageVideoTaskResponseBody(name='body'),
}

async function addStorageVideoTaskWithOptions(request: AddStorageVideoTaskRequest, runtime: Util.RuntimeOptions): AddStorageVideoTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.callbackUrl)) {
    body['CallbackUrl'] = request.callbackUrl;
  }
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.sort)) {
    body['Sort'] = request.sort;
  }
  if (!Util.isUnset(request.storageInfo)) {
    body['StorageInfo'] = request.storageInfo;
  }
  if (!Util.isUnset(request.videoFile)) {
    body['VideoFile'] = request.videoFile;
  }
  if (!Util.isUnset(request.videoId)) {
    body['VideoId'] = request.videoId;
  }
  if (!Util.isUnset(request.videoTags)) {
    body['VideoTags'] = request.videoTags;
  }
  if (!Util.isUnset(request.videoUrl)) {
    body['VideoUrl'] = request.videoUrl;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AddStorageVideoTask',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addStorageVideoTask(request: AddStorageVideoTaskRequest): AddStorageVideoTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return addStorageVideoTaskWithOptions(request, runtime);
}

async function addStorageVideoTaskAdvance(request: AddStorageVideoTaskAdvanceRequest, runtime: Util.RuntimeOptions): AddStorageVideoTaskResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.isUnset(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videosearch',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = null;

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var addStorageVideoTaskReq = new AddStorageVideoTaskRequest{};
  OpenApiUtil.convert(request, addStorageVideoTaskReq);

  if(!Util.isUnset(request.videoFileObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.videoFileObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    addStorageVideoTaskReq.videoFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var addStorageVideoTaskResp = addStorageVideoTaskWithOptions(addStorageVideoTaskReq, runtime);
  return addStorageVideoTaskResp;
}

model CancelBatchTaskRequest {
  batchTaskId?: long(name='BatchTaskId'),
}

model CancelBatchTaskResponseBody = {
  data?: boolean(name='Data'),
  requestId?: string(name='RequestId'),
}

model CancelBatchTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CancelBatchTaskResponseBody(name='body'),
}

async function cancelBatchTaskWithOptions(request: CancelBatchTaskRequest, runtime: Util.RuntimeOptions): CancelBatchTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.batchTaskId)) {
    query['BatchTaskId'] = request.batchTaskId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CancelBatchTask',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function cancelBatchTask(request: CancelBatchTaskRequest): CancelBatchTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return cancelBatchTaskWithOptions(request, runtime);
}

model CreateBatchTaskRequest {
  batchTaskType?: int32(name='BatchTaskType', example='1'),
  callbackUrl?: string(name='CallbackUrl', example='http://xxx'),
  clientToken?: string(name='ClientToken', example='C86D03D1-253E-6832-A4B1-195F945BCEEB'),
  fileUrl?: string(name='FileUrl', example='http://xxx.ab***dx.com/testMeta.json'),
  instanceId?: string(name='InstanceId', example='vs-tyjjhgyu***xdfd'),
  ossBucketName?: string(name='OssBucketName', example='testBucket'),
  ossDataPath?: string(name='OssDataPath', example='testPath/testName'),
  ossMetaFile?: string(name='OssMetaFile', example='testMeta.json'),
  roleArn?: string(name='RoleArn'),
}

model CreateBatchTaskAdvanceRequest {
  batchTaskType?: int32(name='BatchTaskType', example='1'),
  callbackUrl?: string(name='CallbackUrl', example='http://xxx'),
  clientToken?: string(name='ClientToken', example='C86D03D1-253E-6832-A4B1-195F945BCEEB'),
  fileUrlObject?: readable(name='FileUrl', example='http://xxx.ab***dx.com/testMeta.json'),
  instanceId?: string(name='InstanceId', example='vs-tyjjhgyu***xdfd'),
  ossBucketName?: string(name='OssBucketName', example='testBucket'),
  ossDataPath?: string(name='OssDataPath', example='testPath/testName'),
  ossMetaFile?: string(name='OssMetaFile', example='testMeta.json'),
  roleArn?: string(name='RoleArn'),
}

model CreateBatchTaskResponseBody = {
  requestId?: string(name='RequestId', example='C86D03D1-253E-4462-A4B1-195F945BCEEB'),
  taskId?: long(name='TaskId', example='105312'),
}

model CreateBatchTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateBatchTaskResponseBody(name='body'),
}

async function createBatchTaskWithOptions(request: CreateBatchTaskRequest, runtime: Util.RuntimeOptions): CreateBatchTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.batchTaskType)) {
    body['BatchTaskType'] = request.batchTaskType;
  }
  if (!Util.isUnset(request.callbackUrl)) {
    body['CallbackUrl'] = request.callbackUrl;
  }
  if (!Util.isUnset(request.fileUrl)) {
    body['FileUrl'] = request.fileUrl;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.ossBucketName)) {
    body['OssBucketName'] = request.ossBucketName;
  }
  if (!Util.isUnset(request.ossDataPath)) {
    body['OssDataPath'] = request.ossDataPath;
  }
  if (!Util.isUnset(request.ossMetaFile)) {
    body['OssMetaFile'] = request.ossMetaFile;
  }
  if (!Util.isUnset(request.roleArn)) {
    body['RoleArn'] = request.roleArn;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateBatchTask',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createBatchTask(request: CreateBatchTaskRequest): CreateBatchTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return createBatchTaskWithOptions(request, runtime);
}

async function createBatchTaskAdvance(request: CreateBatchTaskAdvanceRequest, runtime: Util.RuntimeOptions): CreateBatchTaskResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if(Util.isUnset(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if(Util.isUnset(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApi.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'videosearch',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = null;

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var createBatchTaskReq = new CreateBatchTaskRequest{};
  OpenApiUtil.convert(request, createBatchTaskReq);

  if(!Util.isUnset(request.fileUrlObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.fileUrlObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    createBatchTaskReq.fileUrl = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var createBatchTaskResp = createBatchTaskWithOptions(createBatchTaskReq, runtime);
  return createBatchTaskResp;
}

model GetAudioInstanceRequest {
  clientToken?: string(name='ClientToken', example='123'),
  instanceId?: string(name='InstanceId', example='1'),
}

model GetAudioInstanceResponseBody = {
  data?: {
    audioInfoUpdateTime?: long(name='AudioInfoUpdateTime', example='1618396147'),
    audioNumber?: int32(name='AudioNumber', example='123'),
    bundlingType?: string(name='BundlingType', example='PREPAY'),
    concurrencyNumber?: int32(name='ConcurrencyNumber', example='1'),
    createTime?: long(name='CreateTime', example='1618396147'),
    currentAudioCapacity?: string(name='CurrentAudioCapacity', example='1'),
    expireTime?: long(name='ExpireTime', example='1618396147'),
    instanceId?: string(name='InstanceId', example='123'),
    instanceName?: string(name='InstanceName', example='test'),
    instanceStatus?: int32(name='InstanceStatus', example='1'),
    maxAudioCapacity?: string(name='MaxAudioCapacity', example='1'),
    regionId?: string(name='RegionId', example='123'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='xxx'),
}

model GetAudioInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetAudioInstanceResponseBody(name='body'),
}

async function getAudioInstanceWithOptions(request: GetAudioInstanceRequest, runtime: Util.RuntimeOptions): GetAudioInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetAudioInstance',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getAudioInstance(request: GetAudioInstanceRequest): GetAudioInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAudioInstanceWithOptions(request, runtime);
}

model GetAudioStorageHistoryRequest {
  audioId?: string(name='AudioId', example='1'),
  clientToken?: string(name='ClientToken', example='1'),
  instanceId?: string(name='InstanceId', example='1'),
  pageNumber?: int32(name='PageNumber', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
}

model GetAudioStorageHistoryResponseBody = {
  data?: {
    count?: long(name='Count', example='0'),
    list?: [ 
      {
        audioId?: string(name='AudioId', example='1'),
        audioUrl?: string(name='AudioUrl', example='http://xxx'),
        description?: string(name='Description'),
        modifiedTime?: long(name='ModifiedTime', example='1618396147'),
        storageInfo?: int32(name='StorageInfo', example='1'),
        storageType?: int32(name='StorageType', example='1'),
      }
    ](name='List'),
    pageNumber?: int32(name='PageNumber', example='1'),
    pageSize?: int32(name='PageSize', example='10'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='xxx'),
}

model GetAudioStorageHistoryResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetAudioStorageHistoryResponseBody(name='body'),
}

async function getAudioStorageHistoryWithOptions(request: GetAudioStorageHistoryRequest, runtime: Util.RuntimeOptions): GetAudioStorageHistoryResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.audioId)) {
    query['AudioId'] = request.audioId;
  }
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetAudioStorageHistory',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getAudioStorageHistory(request: GetAudioStorageHistoryRequest): GetAudioStorageHistoryResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAudioStorageHistoryWithOptions(request, runtime);
}

model GetAudioTaskStatusRequest {
  clientToken?: string(name='ClientToken'),
  instanceId?: string(name='InstanceId'),
  taskId?: string(name='TaskId'),
}

model GetAudioTaskStatusResponseBody = {
  data?: int32(name='Data'),
  requestId?: string(name='RequestId'),
  taskInfo?: {
    analysisUseTime?: long(name='AnalysisUseTime'),
    audioId?: string(name='AudioId'),
    audioTags?: string(name='AudioTags'),
    audioUrl?: string(name='AudioUrl'),
    description?: string(name='Description'),
    duration?: float(name='Duration'),
    errorInfo?: string(name='ErrorInfo'),
    finishTime?: long(name='FinishTime'),
    processResultOss?: string(name='ProcessResultOss'),
    queryTags?: string(name='QueryTags'),
    replaceStorageThreshold?: string(name='ReplaceStorageThreshold'),
    resourceType?: string(name='ResourceType'),
    status?: int32(name='Status'),
    storageInfo?: int32(name='StorageInfo'),
    submitTime?: long(name='SubmitTime'),
    taskId?: long(name='TaskId'),
  }(name='TaskInfo'),
}

model GetAudioTaskStatusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetAudioTaskStatusResponseBody(name='body'),
}

async function getAudioTaskStatusWithOptions(request: GetAudioTaskStatusRequest, runtime: Util.RuntimeOptions): GetAudioTaskStatusResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.taskId)) {
    body['TaskId'] = request.taskId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetAudioTaskStatus',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getAudioTaskStatus(request: GetAudioTaskStatusRequest): GetAudioTaskStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAudioTaskStatusWithOptions(request, runtime);
}

model GetBatchTaskRequest {
  batchTaskId?: long(name='BatchTaskId', example='1'),
  clientToken?: string(name='ClientToken', example='123'),
  instanceId?: string(name='InstanceId', example='123'),
}

model GetBatchTaskResponseBody = {
  batchTaskId?: long(name='BatchTaskId', example='1'),
  modifiedTime?: long(name='ModifiedTime', example='1618396147'),
  processMessage?: string(name='ProcessMessage', example='xxx'),
  requestId?: string(name='RequestId', example='xxx'),
  status?: int32(name='Status', example='1'),
  subTaskDetail?: string(name='SubTaskDetail', example='http://xxx'),
}

model GetBatchTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetBatchTaskResponseBody(name='body'),
}

async function getBatchTaskWithOptions(request: GetBatchTaskRequest, runtime: Util.RuntimeOptions): GetBatchTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.batchTaskId)) {
    body['BatchTaskId'] = request.batchTaskId;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetBatchTask',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getBatchTask(request: GetBatchTaskRequest): GetBatchTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return getBatchTaskWithOptions(request, runtime);
}

model GetInstanceRequest {
  clientToken?: string(name='ClientToken', example='123'),
  instanceId?: string(name='InstanceId', example='vs123'),
}

model GetInstanceResponseBody = {
  data?: {
    bundlingType?: string(name='BundlingType', example='PREPAY'),
    concurrencyNumber?: int32(name='ConcurrencyNumber', example='5'),
    createTime?: long(name='CreateTime', example='1618396147000'),
    currentVideoCapacity?: string(name='CurrentVideoCapacity', example='1235701'),
    expireTime?: long(name='ExpireTime', example='1618396147000'),
    instanceId?: string(name='InstanceId', example='vs-123'),
    instanceName?: string(name='InstanceName'),
    instanceStatus?: int32(name='InstanceStatus', example='3'),
    maxVideoCapacity?: string(name='MaxVideoCapacity', example='2000'),
    regionId?: string(name='RegionId', example='cn-beijing'),
    videoInfoUpdateTime?: long(name='VideoInfoUpdateTime', example='1618396147000'),
    videoNumber?: int32(name='VideoNumber', example='12356'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='abc23-def145'),
}

model GetInstanceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetInstanceResponseBody(name='body'),
}

async function getInstanceWithOptions(request: GetInstanceRequest, runtime: Util.RuntimeOptions): GetInstanceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetInstance',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getInstance(request: GetInstanceRequest): GetInstanceResponse {
  var runtime = new Util.RuntimeOptions{};
  return getInstanceWithOptions(request, runtime);
}

model GetStorageHistoryRequest {
  clientToken?: string(name='ClientToken', example='clientToken'),
  instanceId?: string(name='InstanceId', example='vs-ih****wj'),
  pageNumber?: int32(name='PageNumber', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
  videoId?: string(name='VideoId', example='testVideoId'),
}

model GetStorageHistoryResponseBody = {
  data?: {
    count?: long(name='Count', example='28'),
    list?: [ 
      {
        description?: string(name='Description'),
        modifiedTime?: long(name='ModifiedTime', example='667864577541000'),
        storageInfo?: int32(name='StorageInfo', example='1'),
        storageType?: int32(name='StorageType', example='1'),
        videoId?: string(name='VideoId', example='testVideoId'),
        videoUrl?: string(name='VideoUrl', example='https://testVideo.aliyuncs.com'),
      }
    ](name='List'),
    pageNumber?: int32(name='PageNumber', example='1'),
    pageSize?: int32(name='PageSize', example='10'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='38D33983-6CEC-4D47-9803-2F6B18A759E9'),
}

model GetStorageHistoryResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetStorageHistoryResponseBody(name='body'),
}

async function getStorageHistoryWithOptions(request: GetStorageHistoryRequest, runtime: Util.RuntimeOptions): GetStorageHistoryResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.videoId)) {
    query['VideoId'] = request.videoId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetStorageHistory',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getStorageHistory(request: GetStorageHistoryRequest): GetStorageHistoryResponse {
  var runtime = new Util.RuntimeOptions{};
  return getStorageHistoryWithOptions(request, runtime);
}

model GetTaskStatusRequest {
  clientToken?: string(name='ClientToken', example='clientToken'),
  instanceId?: string(name='InstanceId', example='vs-ihc****wj'),
  taskId?: string(name='TaskId', example='100001'),
}

model GetTaskStatusResponseBody = {
  data?: int32(name='Data', example='1'),
  requestId?: string(name='RequestId', example='1ABBE852-6313-49F9-BF8A-6FDF9A4C0617'),
  taskInfo?: {
    analysisUseTime?: long(name='AnalysisUseTime', example='21'),
    description?: string(name='Description'),
    duration?: float(name='Duration', example='186.75'),
    errorInfo?: string(name='ErrorInfo'),
    finishTime?: long(name='FinishTime', example='6754336754000'),
    processResultOss?: string(name='ProcessResultOss', example='https://result*******.aliyuncs.com/xxxxx/test'),
    queryTags?: string(name='QueryTags', example='testQueryTag'),
    replaceStorageThreshold?: string(name='ReplaceStorageThreshold', example='0.95'),
    resolution?: string(name='Resolution', example='320*160'),
    resourceType?: string(name='ResourceType', example='1'),
    status?: int32(name='Status', example='3'),
    storageInfo?: int32(name='StorageInfo', example='1'),
    storageType?: int32(name='StorageType'),
    submitTime?: long(name='SubmitTime', example='169876556900'),
    taskId?: long(name='TaskId', example='19056'),
    videoId?: string(name='VideoId', example='testVideoId'),
    videoTags?: string(name='VideoTags', example='testVideoTag'),
    videoUrl?: string(name='VideoUrl', example='https://testVideo.aliyuncs.com/xxxxx'),
  }(name='TaskInfo'),
}

model GetTaskStatusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetTaskStatusResponseBody(name='body'),
}

async function getTaskStatusWithOptions(request: GetTaskStatusRequest, runtime: Util.RuntimeOptions): GetTaskStatusResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.taskId)) {
    body['TaskId'] = request.taskId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetTaskStatus',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getTaskStatus(request: GetTaskStatusRequest): GetTaskStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return getTaskStatusWithOptions(request, runtime);
}

model ListBatchTaskRequest {
  batchTaskType?: string(name='BatchTaskType', example='1'),
  bucketName?: string(name='BucketName', example='testBucket'),
  clientToken?: string(name='ClientToken', example='C86D03D1-253E-4462-A4B1-195F945BCEEB'),
  dataPath?: string(name='DataPath', example='testPath'),
  instanceId?: string(name='InstanceId', example='vs-abcabc***abc'),
  pageNumber?: long(name='PageNumber', example='1'),
  pageSize?: long(name='PageSize', example='10'),
  status?: string(name='Status', example='1'),
}

model ListBatchTaskResponseBody = {
  data?: {
    count?: long(name='Count', example='1007'),
    list?: [ 
      {
        arn?: string(name='Arn', example='xxx'),
        bucketName?: string(name='BucketName'),
        dataPath?: string(name='DataPath'),
        metaFile?: string(name='MetaFile'),
        modifiedTime?: long(name='ModifiedTime', example='1618396147'),
        processMessage?: string(name='ProcessMessage', example='http://mult***re.oss-cn-hangzhou.aliyuncs.com/batchProcessMessage//1989587002255388/096cae3e-5a0e-4cb6-9f07-9d9cb81f9b95?Expires=1601449075&OSSAccessKeyId=LTAI4Fsi******Y7maLLvP&Signature=jdbmaJ2rKY5%2B*****2h6E8U0%3D'),
        regionId?: string(name='RegionId', example='cn-hangzhou'),
        status?: int32(name='Status', example='2'),
        subTaskDetail?: string(name='SubTaskDetail', example='http://xxx'),
        taskId?: string(name='TaskId', example='10876'),
        taskType?: int32(name='TaskType', example='1'),
      }
    ](name='List'),
    pageNumber?: long(name='PageNumber', example='1'),
    pageSize?: long(name='PageSize', example='10'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='C86D03D1-253E-4462-A4B1-195F945BCEEB'),
}

model ListBatchTaskResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListBatchTaskResponseBody(name='body'),
}

async function listBatchTaskWithOptions(request: ListBatchTaskRequest, runtime: Util.RuntimeOptions): ListBatchTaskResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.batchTaskType)) {
    query['BatchTaskType'] = request.batchTaskType;
  }
  if (!Util.isUnset(request.bucketName)) {
    query['BucketName'] = request.bucketName;
  }
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.dataPath)) {
    query['DataPath'] = request.dataPath;
  }
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.status)) {
    query['Status'] = request.status;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListBatchTask',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listBatchTask(request: ListBatchTaskRequest): ListBatchTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  return listBatchTaskWithOptions(request, runtime);
}

model ListInstancesRequest {
  clientToken?: string(name='ClientToken', example='xxx'),
  instanceName?: string(name='InstanceName', example='test'),
  instanceType?: int32(name='InstanceType', example='1'),
  pageNumber?: int32(name='PageNumber', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
  status?: int32(name='Status', example='1'),
  tags?: string(name='Tags', example='testTags'),
}

model ListInstancesResponseBody = {
  data?: {
    count?: long(name='Count', example='0'),
    list?: [ 
      {
        createTime?: string(name='CreateTime', example='1618396147'),
        expiredTime?: string(name='ExpiredTime', example='1618396147'),
        instanceId?: string(name='InstanceId', example='1'),
        instanceName?: string(name='InstanceName', example='test'),
        instanceStatus?: int32(name='InstanceStatus', example='1'),
        tags?: [ 
          {
            key?: string(name='Key', example='key'),
            value?: string(name='Value', example='value'),
          }
        ](name='Tags'),
      }
    ](name='List'),
    pageNumber?: int32(name='PageNumber', example='1'),
    pageSize?: int32(name='PageSize', example='10'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='xxx'),
}

model ListInstancesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListInstancesResponseBody(name='body'),
}

async function listInstancesWithOptions(request: ListInstancesRequest, runtime: Util.RuntimeOptions): ListInstancesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceName)) {
    body['InstanceName'] = request.instanceName;
  }
  if (!Util.isUnset(request.instanceType)) {
    body['InstanceType'] = request.instanceType;
  }
  if (!Util.isUnset(request.pageNumber)) {
    body['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.status)) {
    body['Status'] = request.status;
  }
  if (!Util.isUnset(request.tags)) {
    body['Tags'] = request.tags;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListInstances',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listInstances(request: ListInstancesRequest): ListInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listInstancesWithOptions(request, runtime);
}

model ListSearchAudioTasksRequest {
  clientToken?: string(name='ClientToken', example='1'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='i12345678'),
  pageNumber?: int32(name='PageNumber', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
  sortList?: string(name='SortList', example='[1,2]'),
  statusList?: string(name='StatusList', example='[1,2]'),
  taskId?: string(name='TaskId', example='1'),
}

model ListSearchAudioTasksResponseBody = {
  data?: {
    count?: long(name='Count', example='1'),
    pageNumber?: int32(name='PageNumber', example='1'),
    pageSize?: int32(name='PageSize', example='10'),
    taskList?: [ 
      {
        audioId?: string(name='AudioId', example='1'),
        audioTags?: string(name='AudioTags', example='test'),
        audioUrl?: string(name='AudioUrl', example='http://xxx.mp4'),
        description?: string(name='Description'),
        errorDetail?: string(name='ErrorDetail'),
        modifiedTime?: long(name='ModifiedTime', example='1618396147'),
        processResultUrl?: string(name='ProcessResultUrl', example='http://xxx'),
        processTime?: long(name='ProcessTime', example='10'),
        remoteTaskId?: string(name='RemoteTaskId', example='1'),
        sort?: int32(name='Sort', example='1'),
        status?: int32(name='Status', example='1'),
        storageInfo?: int32(name='StorageInfo', example='1'),
        taskId?: string(name='TaskId', example='1'),
      }
    ](name='TaskList'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='123'),
}

model ListSearchAudioTasksResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListSearchAudioTasksResponseBody(name='body'),
}

async function listSearchAudioTasksWithOptions(request: ListSearchAudioTasksRequest, runtime: Util.RuntimeOptions): ListSearchAudioTasksResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.pageNumber)) {
    body['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.sortList)) {
    body['SortList'] = request.sortList;
  }
  if (!Util.isUnset(request.statusList)) {
    body['StatusList'] = request.statusList;
  }
  if (!Util.isUnset(request.taskId)) {
    body['TaskId'] = request.taskId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListSearchAudioTasks',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listSearchAudioTasks(request: ListSearchAudioTasksRequest): ListSearchAudioTasksResponse {
  var runtime = new Util.RuntimeOptions{};
  return listSearchAudioTasksWithOptions(request, runtime);
}

model ListSearchVideoTasksRequest {
  clientToken?: string(name='ClientToken', example='123'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='1'),
  pageNumber?: int32(name='PageNumber', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
  searchTypeList?: string(name='SearchTypeList', example='[1,2]'),
  sortList?: string(name='SortList', example='[1,2]'),
  statusList?: string(name='StatusList', example='[1,2]'),
  taskId?: string(name='TaskId', example='1'),
  videoId?: string(name='VideoId', example='1'),
  videoName?: string(name='VideoName', example='testVideoName'),
}

model ListSearchVideoTasksResponseBody = {
  data?: {
    count?: long(name='Count', example='0'),
    pageNumber?: int32(name='PageNumber', example='1'),
    pageSize?: int32(name='PageSize', example='10'),
    taskList?: [ 
      {
        description?: string(name='Description'),
        errorDetail?: string(name='ErrorDetail', example='xxx'),
        modifiedTime?: long(name='ModifiedTime', example='1618396147'),
        processResultUrl?: string(name='ProcessResultUrl', example='http://xxx'),
        processTime?: long(name='ProcessTime', example='10'),
        queryTags?: string(name='QueryTags', example='xxx'),
        remoteTaskId?: string(name='RemoteTaskId', example='1'),
        replaceStorageThreshold?: string(name='ReplaceStorageThreshold', example='0.5'),
        searchType?: int32(name='SearchType', example='1'),
        sort?: int32(name='Sort', example='1'),
        status?: int32(name='Status', example='2'),
        storageInfo?: int32(name='StorageInfo', example='1'),
        storageType?: int32(name='StorageType', example='1'),
        taskId?: string(name='TaskId', example='123'),
        videoId?: string(name='VideoId', example='123'),
        videoName?: string(name='VideoName', example='testName'),
        videoTags?: string(name='VideoTags', example='xxx'),
        videoUrl?: string(name='VideoUrl', example='http://xxx'),
      }
    ](name='TaskList'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='123'),
}

model ListSearchVideoTasksResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListSearchVideoTasksResponseBody(name='body'),
}

async function listSearchVideoTasksWithOptions(request: ListSearchVideoTasksRequest, runtime: Util.RuntimeOptions): ListSearchVideoTasksResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.pageNumber)) {
    body['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.searchTypeList)) {
    body['SearchTypeList'] = request.searchTypeList;
  }
  if (!Util.isUnset(request.sortList)) {
    body['SortList'] = request.sortList;
  }
  if (!Util.isUnset(request.statusList)) {
    body['StatusList'] = request.statusList;
  }
  if (!Util.isUnset(request.taskId)) {
    body['TaskId'] = request.taskId;
  }
  if (!Util.isUnset(request.videoId)) {
    body['VideoId'] = request.videoId;
  }
  if (!Util.isUnset(request.videoName)) {
    body['VideoName'] = request.videoName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListSearchVideoTasks',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listSearchVideoTasks(request: ListSearchVideoTasksRequest): ListSearchVideoTasksResponse {
  var runtime = new Util.RuntimeOptions{};
  return listSearchVideoTasksWithOptions(request, runtime);
}

model ListStorageAudioTasksRequest {
  audioId?: string(name='AudioId', example='123'),
  clientToken?: string(name='ClientToken', example='1'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='xx-ixxxx'),
  pageNumber?: int32(name='PageNumber', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
  sortList?: string(name='SortList', example='[1,2]'),
  statusList?: string(name='StatusList', example='[1,2]'),
  storageInfoList?: string(name='StorageInfoList', example='[1,2]'),
  taskId?: string(name='TaskId', example='1'),
}

model ListStorageAudioTasksResponseBody = {
  data?: {
    count?: long(name='Count', example='1'),
    pageNumber?: int32(name='PageNumber', example='1'),
    pageSize?: int32(name='PageSize', example='10'),
    taskList?: [ 
      {
        audioId?: string(name='AudioId', example='1'),
        audioUrl?: string(name='AudioUrl', example='http://xxx'),
        description?: string(name='Description'),
        errorDetail?: string(name='ErrorDetail'),
        processTime?: long(name='ProcessTime', example='1'),
        remoteTaskId?: string(name='RemoteTaskId', example='1'),
        sort?: int32(name='Sort', example='1'),
        status?: string(name='Status', example='1'),
        storageInfo?: int32(name='StorageInfo', example='1'),
        taskId?: long(name='TaskId', example='1'),
        updateTime?: long(name='UpdateTime', example='1618396147'),
      }
    ](name='TaskList'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='123'),
}

model ListStorageAudioTasksResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListStorageAudioTasksResponseBody(name='body'),
}

async function listStorageAudioTasksWithOptions(request: ListStorageAudioTasksRequest, runtime: Util.RuntimeOptions): ListStorageAudioTasksResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.audioId)) {
    body['AudioId'] = request.audioId;
  }
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.pageNumber)) {
    body['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.sortList)) {
    body['SortList'] = request.sortList;
  }
  if (!Util.isUnset(request.statusList)) {
    body['StatusList'] = request.statusList;
  }
  if (!Util.isUnset(request.storageInfoList)) {
    body['StorageInfoList'] = request.storageInfoList;
  }
  if (!Util.isUnset(request.taskId)) {
    body['TaskId'] = request.taskId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListStorageAudioTasks',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listStorageAudioTasks(request: ListStorageAudioTasksRequest): ListStorageAudioTasksResponse {
  var runtime = new Util.RuntimeOptions{};
  return listStorageAudioTasksWithOptions(request, runtime);
}

model ListStorageVideoTasksRequest {
  clientToken?: string(name='ClientToken', example='123'),
  description?: string(name='Description'),
  instanceId?: string(name='InstanceId', example='xxx'),
  pageNumber?: int32(name='PageNumber', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
  sortList?: string(name='SortList', example='[1]'),
  statusList?: string(name='StatusList', example='[1,2]'),
  storageInfoList?: string(name='StorageInfoList', example='[1,2]'),
  taskId?: string(name='TaskId', example='123'),
  videoId?: string(name='VideoId', example='1'),
  videoName?: string(name='VideoName', example='testName'),
}

model ListStorageVideoTasksResponseBody = {
  data?: {
    count?: long(name='Count', example='0'),
    pageNumber?: int32(name='PageNumber', example='1'),
    pageSize?: int32(name='PageSize', example='10'),
    taskList?: [ 
      {
        description?: string(name='Description'),
        errorDetail?: string(name='ErrorDetail', example='xxx'),
        modifiedTime?: long(name='ModifiedTime', example='1618396147'),
        processTime?: long(name='ProcessTime', example='10'),
        remoteTaskId?: string(name='RemoteTaskId', example='1'),
        sort?: int32(name='Sort', example='1'),
        status?: string(name='Status', example='1'),
        storageInfo?: int32(name='StorageInfo', example='1'),
        taskId?: long(name='TaskId', example='1'),
        videoId?: string(name='VideoId', example='1'),
        videoName?: string(name='VideoName', example='testName'),
        videoUrl?: string(name='VideoUrl', example='http://xxx'),
      }
    ](name='TaskList'),
  }(name='Data'),
  requestId?: string(name='RequestId', example='123'),
}

model ListStorageVideoTasksResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListStorageVideoTasksResponseBody(name='body'),
}

async function listStorageVideoTasksWithOptions(request: ListStorageVideoTasksRequest, runtime: Util.RuntimeOptions): ListStorageVideoTasksResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.description)) {
    body['Description'] = request.description;
  }
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.pageNumber)) {
    body['PageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.sortList)) {
    body['SortList'] = request.sortList;
  }
  if (!Util.isUnset(request.statusList)) {
    body['StatusList'] = request.statusList;
  }
  if (!Util.isUnset(request.storageInfoList)) {
    body['StorageInfoList'] = request.storageInfoList;
  }
  if (!Util.isUnset(request.taskId)) {
    body['TaskId'] = request.taskId;
  }
  if (!Util.isUnset(request.videoId)) {
    body['VideoId'] = request.videoId;
  }
  if (!Util.isUnset(request.videoName)) {
    body['VideoName'] = request.videoName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListStorageVideoTasks',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listStorageVideoTasks(request: ListStorageVideoTasksRequest): ListStorageVideoTasksResponse {
  var runtime = new Util.RuntimeOptions{};
  return listStorageVideoTasksWithOptions(request, runtime);
}

model ModifyPriorityRequest {
  clientToken?: string(name='ClientToken', example='123'),
  sort?: int32(name='Sort', example='1'),
  taskId?: string(name='TaskId', example='123'),
}

model ModifyPriorityResponseBody = {
  data?: boolean(name='Data', example='true'),
  requestId?: string(name='RequestId', example='xxx'),
}

model ModifyPriorityResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ModifyPriorityResponseBody(name='body'),
}

async function modifyPriorityWithOptions(request: ModifyPriorityRequest, runtime: Util.RuntimeOptions): ModifyPriorityResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.clientToken)) {
    query['ClientToken'] = request.clientToken;
  }
  if (!Util.isUnset(request.taskId)) {
    query['TaskId'] = request.taskId;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.sort)) {
    body['Sort'] = request.sort;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ModifyPriority',
    version = '2020-02-25',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function modifyPriority(request: ModifyPriorityRequest): ModifyPriorityResponse {
  var runtime = new Util.RuntimeOptions{};
  return modifyPriorityWithOptions(request, runtime);
}

